/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.emex.app.web.service;

import com.emex.app.shared.data.OrderPosition;
import com.emex.app.shared.data.OrderPositionExample;
import com.emex.app.shared.persistance.OrderPositionMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Sergey Karavaev
 */
@Service
@Transactional
public class OrderPositionService {

    @Autowired
    private OrderPositionMapper orderPositionMapper;

    public int deleteOrderPositionByPrimaryKey(Integer id) {
        return orderPositionMapper.deleteByPrimaryKey(id);
    }

    public OrderPosition insertOrderPosition(OrderPosition record) {
        orderPositionMapper.insert(record);
        return record;
    }

    public List<OrderPosition> selectOrderPositionByExample(OrderPositionExample example) {
        return orderPositionMapper.selectByExample(example);
    }

    public OrderPosition selectOrderPositionByPrimaryKey(Integer id) {
        return orderPositionMapper.selectByPrimaryKey(id);
    }

    public OrderPosition updateOrderPositionByPrimaryKey(OrderPosition record) {
        orderPositionMapper.updateByPrimaryKey(record);
        return record;
    }

    public List<OrderPosition> getOrderPositionByOrderId(Integer orderId) {
        OrderPositionExample example = new OrderPositionExample();
        example.createCriteria().andOrderIdEqualTo(orderId);
        return selectOrderPositionByExample(example);
    }
    
    public List<OrderPosition> getOrderPositionsByName(String name) {
        OrderPositionExample example = new OrderPositionExample();
        example.createCriteria().andNameLike(name);
        return selectOrderPositionByExample(example);
    }
}
